IdeaBlade DevForce 2010 Help Reference
EntitySpan Constructor(Type,EntityRelation[])
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntitySpan Class > EntitySpan Constructor : EntitySpan Constructor(Type,EntityRelation[])



fromType
Root Entity type
entityRelations
One or more entity relations
Initializes a new instance of the EntitySpan class.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal fromType As Type, _
   ByVal ParamArray entityRelations() As EntityRelation _
)
Visual Basic (Usage)Copy Code
Dim fromType As Type
Dim entityRelations() As EntityRelation
 
Dim instance As New EntitySpan(fromType, entityRelations)
C# 
public EntitySpan( 
   Type fromType,
   params EntityRelation[] entityRelations
)
C++/CLI 
public:
EntitySpan( 
   Type^ fromType,
   ... array<EntityRelation^>^ entityRelations
)

Parameters

fromType
Root Entity type
entityRelations
One or more entity relations

Exceptions

ExceptionDescription
System.ArgumentExceptionThrown if the relationships are ambiguous or do not connect

Example

C#Copy Code
public void FindEntityGraph() {

  DomainModelEntityManager mgr = new DomainModelEntityManager();
  
  // Preload some data into cache for this example.
  var emp = mgr.Employees.Where(e => e.Id == 1).Include("OrderSummaries.OrderDetails.Product").ToList().First();

  // Get a product for this example.
  Product p = mgr.FindEntities<Product>(EntityState.Unchanged).First();


  // Now retrieve an object graph for the selected product.
  var roots = new List<Entity> { p };

  // Add spans - we want any order details using this product, their orders, and the employees.
  // Note you must be able to "walk" all relations in the single EntitySpan, if you can't then
  // you should use additional EntitySpans.
  EntitySpan span1 = new EntitySpan(typeof(Product), 
    EntityRelations.FK_Order_Details_Products, 
    EntityRelations.FK_Order_Details_Orders, 
    EntityRelations.FK_OrderSummary_Employee);

  var spans = new List<EntitySpan> { span1 };

  // Get the entity graph
  var entityGraph = mgr.FindEntityGraph(roots, spans, EntityState.Unchanged);

}

Remarks

A single EntitySpan represents the relations among a graph of entities. You must be able to "walk" the spans without jumping or backtracking.

The EntitySpan is used in retrieving an entity graph with EntityManager.FindEntityGraph

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.